﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FantastPlatform.Community.IMode;
using FantastPlatform.Community.Model;
using FantastPlatform.Framework.Service;
using FantastPlatform.Community.IService;
using NHibernate;
using NHibernate.Criterion;

namespace FantastPlatform.Community.Service
{
    public class MailListService : DataService<IMailList, MailList>, IMailListService
    {
        public IMailList GetByPhoneNumber(string phoneNumber)
        {
            ICriteria criteria = Session.CreateCriteria(typeof(MailList));
            criteria.Add(Expression.Eq("PhoneNumber", phoneNumber)).Add(Expression.Eq("Enable", true));
            IList<IMailList> list = criteria.List<IMailList>();
            if (list.Count > 0)
                return list[0];
            else
                return null;
        }
    }
}